package com.ruoyi.company_Management.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.company_Management.domain.Honor;
import com.ruoyi.company_Management.service.IHonorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司荣誉Controller
 * 
 * @author why
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/company_Management/honor")
public class HonorController extends BaseController
{
    @Autowired
    private IHonorService honorService;

    /**
     * 查询公司荣誉列表
     */
    @PreAuthorize("@ss.hasPermi('company_Management:honor:list')")
    @GetMapping("/list")
    public TableDataInfo list(Honor honor)
    {
        startPage();
        List<Honor> list = honorService.selectHonorList(honor);
        return getDataTable(list);
    }

    /**
     * 导出公司荣誉列表
     */
    @PreAuthorize("@ss.hasPermi('company_Management:honor:export')")
    @Log(title = "公司荣誉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Honor honor)
    {
        List<Honor> list = honorService.selectHonorList(honor);
        ExcelUtil<Honor> util = new ExcelUtil<Honor>(Honor.class);
        util.exportExcel(response, list, "公司荣誉数据");
    }

    /**
     * 获取公司荣誉详细信息
     */
    @PreAuthorize("@ss.hasPermi('company_Management:honor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(honorService.selectHonorById(id));
    }

    /**
     * 新增公司荣誉
     */
    @PreAuthorize("@ss.hasPermi('company_Management:honor:add')")
    @Log(title = "公司荣誉", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Honor honor)
    {
        return toAjax(honorService.insertHonor(honor));
    }

    /**
     * 修改公司荣誉
     */
    @PreAuthorize("@ss.hasPermi('company_Management:honor:edit')")
    @Log(title = "公司荣誉", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Honor honor)
    {
        return toAjax(honorService.updateHonor(honor));
    }

    /**
     * 删除公司荣誉
     */
    @PreAuthorize("@ss.hasPermi('company_Management:honor:remove')")
    @Log(title = "公司荣誉", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(honorService.deleteHonorByIds(ids));
    }

    @Anonymous
    @GetMapping("/list1")
    public TableDataInfo list1(Honor honor)
    {
        startPage();
        List<Honor> list = honorService.selectHonorList(honor);
        return getDataTable(list);
    }
}
